package com.example.fanplant.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.fanplant.model.JSONResult;
import com.example.fanplant.model.Test;
import com.example.fanplant.model.User;
import com.example.fanplant.respository.TestRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@RestController
@RequestMapping("/hello")
public class HelloController {
    /*
     * 2、通过HttpServletRequest接收    http://120.53.17.106:8080/hello/get_result
     */

    @RequestMapping("/get_result")
    public JSONObject test_access_request(HttpServletRequest request) {

        Users test = new Users("关晓彤", "女", "北京欢迎你！！");
        JSONResult jsonResult = new JSONResult(0, "get result success", test);

        return jsonResult.getJson();
    }

}

class Users {

    private String name;
    private String gender;
    private String content;

    public Users(String name, String gender, String content) {
        this.name = name;
        this.gender = gender;
        this.content = content;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

}
